﻿using System;
using System.Data;
using System.Configuration;
using System.Data.OleDb;
using System.Web;
/// <summary>
/// DbError 的摘要说明
/// </summary>
public class DbError
{
	static DbError()
	{
		//
		// TODO: 在此处添加构造函数逻辑
		//
        connection = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
        //connection = //GetConfigContent.ConnectionStringNews;
        //    "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
        //    HttpContext.Current.Server.MapPath("~/App_Data/rss.mdb");
	}
    public static void WriteErrorMessage(string pageName, string methodName, string errorMessage)
    {
        errorMessage = errorMessage.Length > 100 ? errorMessage.Substring(0, 100) : errorMessage;
        OleDbConnection con = new OleDbConnection(connection);
        OleDbCommand cmd = new OleDbCommand("insert into ToookDbError(PageName,MethodName,ErrorMessage) values(?,?,?)", con);
        cmd.Parameters.Add("PageName", OleDbType.VarChar, 20).Value = pageName;
        cmd.Parameters.Add("MethodName", OleDbType.VarChar, 20).Value = methodName;
        cmd.Parameters.Add("ErrorMessage", OleDbType.VarChar, 100).Value = errorMessage;
        con.Open();
        cmd.ExecuteNonQuery();
        con.Close();
    }
    private static string connection;
}
